//
//  MyAlbumViewController.m
//  PSYWeiBo
//
//  Created by xiaotian on 16/3/16.
//  Copyright © 2016年 郑亚田. All rights reserved.
//

#import "MyAlbumViewController.h"
#import "AlbumColCell.h"
#import "AlbumDetailViewController.h"

@interface MyAlbumViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>

@property (nonatomic,strong)UICollectionView *albumCol;

@end

@implementation MyAlbumViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleLab.text = @"我的相册";
    
    [self setViews];
}

- (void)setViews {
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    flowLayout.itemSize = CGSizeMake(kScreenWidth, kScreenHeight - self.headerImgV.bounds.size.height - 20);
    flowLayout.minimumInteritemSpacing = kScreenWidth/10;
    flowLayout.sectionInset = UIEdgeInsetsMake(kScreenWidth/18, kScreenWidth/9, kScreenWidth/18, kScreenWidth/9);
    
    self.albumCol = [[UICollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.headerImgV.frame), kScreenWidth, kScreenHeight - CGRectGetMaxY(self.headerImgV.frame)) collectionViewLayout:flowLayout];
    [self.view addSubview:self.albumCol];
    [self.albumCol mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headerImgV.mas_bottom).with.offset(-10);
        make.left.right.bottom.equalTo(@0);
    }];
    
    self.albumCol.backgroundColor = [UIColor whiteColor];
    self.albumCol.pagingEnabled = YES;
    self.albumCol.delegate = self;
    self.albumCol.dataSource = self;
    [self.albumCol registerClass:[AlbumColCell class] forCellWithReuseIdentifier:@"albumCell"];
}

#pragma mark - collectionview代理方法
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    AlbumColCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"albumCell" forIndexPath:indexPath];
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(kScreenWidth/3, kScreenWidth/3);
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    AlbumDetailViewController *albumDetail = [AlbumDetailViewController new];
    albumDetail.modalTransitionStyle = 2;
    [self presentViewController:albumDetail animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
